import { Component, OnInit, OnDestroy } from '@angular/core';
import { Router } from '@angular/router';

@Component({
  selector: 'app-code404',
  templateUrl: './code404.component.html',
  styleUrls: ['./code404.component.css']
})
export class Code404Component implements OnInit, OnDestroy {
  count = 1000;
  public timer: any;
  login = 1;
  constructor(public router: Router) { }

  ngOnInit() {
    this.timer = setInterval( () => {
      this.count--;
      console.log(this.count);
      if ( this.count === 0 ) {
        this.login ? window.history.back() : this.router.navigate(['/login']);
      };
    }, 1000)
  }
  ngOnDestroy(): void {
     clearInterval(this.timer);
  }
  goBack() {
    this.login ? window.history.back() : this.router.navigate(['/login']);
  }

}
